{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑非图书</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">商品名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="good_name" lay-verify="required" placeholder="商品名称" class="layui-input" value="{$info.good_name}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">选择类目：</label>
                            <div class="layui-input-block">
                                <select name="good_assortment"  xm-select="select1" lay-verify="required" xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    <option value="" >请选择</option>
                                    {foreach name="cate" item="v"}
                                    <option value="{$v.assortment_id}" {$v.assortment_id == $info.good_assortment?'selected':''}>{$v.assortment_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">成本价：</label>
                            <div class="layui-input-block">
                                <input type="text" name="good_cost" lay-verify="required" placeholder="成本价" class="layui-input" value="{$info.good_cost}">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md10">
                            <label class="layui-form-label">详情：</label>
                            <div class="layui-input-block" id="LAY_editor" lay-verify="editor">
                                <p>{$info.good_content}</p>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图上传：</label>
                            <input type="hidden" name="img1" id="lay-img1" lay-verify="image" value="{$info['good_thumb']}">
                            <div class="layui-input-block">
                                <div id="lay-upload1">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list1">
                                        <img class="layui-append-img" src="{$info['good_thumb']}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">图片：</label>
                            <input type="hidden" name="img" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div class="page-container">
                                    <input type="hidden" name="del" id="del" value="">
                                    <input type="hidden" id="hid" value="{$info.good_image}">
                                    <input type="hidden" name="photo" id="photo" value="{$info.good_image}">
                                    <div id="uploader" class="wu-example">
                                        <div class="queueList">
                                            <div id="dndArea" class="placeholder">
                                                <div id="filePicker"></div>
                                                <p>或将照片拖到这里,支持JPG,JPEG,PNG,BMP,GIF</p >
                                            </div>
                                        </div>
                                        <div class="statusBar" style="display:none;">
                                            <div class="progress progress-striped active">
                                                <div class="progress-bar progress-bar-success">
                                                    <span>0%</span>
                                                </div>
                                            </div>
                                            <div class="info"></div>
                                            <div class="btns">
                                                <div id="filePicker2"></div>
                                                <div class="uploadBtn">开始上传</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">重量(g)：</label>
                            <div class="layui-input-block">
                                <input type="text" name="good_weight" lay-verify="required" placeholder="重量" class="layui-input" value="{$info.good_weight}" oninput="value=value.replace(/[^\d]/g,'')">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">年级：</label>
                            <div class="layui-input-block">
                                <select name="good_grade_id"  xm-select="select2" xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    <option value="" >请选择</option>
                                    {foreach name="data1" item="v1"}
                                    <option value="{$v1.good_name_id}"{if $info['good_grade_id']==$v1['good_name_id']} selected {/if} >{$v1.good_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">其他：</label>
                            <div class="layui-input-block">
                                <select name="good_press_id"  xm-select="select3" xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    <option value="" >请选择</option>
                                    {foreach name="data2" item="v2"}
                                    <option value="{$v2.good_name_id}" {if $info['good_press_id']==$v2['good_name_id']} selected {/if}>{$v2.good_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">类型：</label>
                            <div class="layui-input-block">
                                <select name="good_type_id"  xm-select="select4" xm-select-search="" xm-select-radio="" xm-select-search-type="dl">
                                    <option value="" >请选择</option>
                                    {foreach name="data3" item="v3"}
                                    <option value="{$v3.good_name_id}" {if $info['good_type_id']==$v3['good_name_id']} selected {/if}>{$v3.good_name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <input type="hidden" name="good_id" value="{$good_id}">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="__JS__/webupload/webuploader_update.js"></script>
<script>
    var editor = wk.wang({elem:'#LAY_editor'});
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    wk.uploadImg1({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            data.field.good_content = editor.txt.html();
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('goodsEdit')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Goods/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
        form.on('select(role)', function(data){
            if(data.value == 2){
                $("#good_id").show();
            }else{
                $("#good_id").hide();
            }
        });
    });
</script>

</body>
</html>
